package com.niiwoo.civet.scheduler.trigger;

import com.alibaba.dubbo.config.annotation.Reference;
import com.niiwoo.civet.trade.service.refund.RepaymentDubboService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

/**
 * 消息发送定时任务
 * Created by wuke on 2018/01/18
 */
@Component
@Slf4j
public class MessageSendJobTrigger {
    @Reference(version = "1.0.0")
    private RepaymentDubboService repaymentDubboService;

    /**
     * 还款提醒定时任务
     */
    @Scheduled(cron = "${message.repayment-remind}")
    public void sendRepaymentRemindMessageForJob(){
        try {
            log.info("MessageSendJobTrigger.sendRepaymentRemindMessageForJob start");
            repaymentDubboService.sendRepaymentRemindMessageForJob();
            log.info("MessageSendJobTrigger.sendRepaymentRemindMessageForJob end");
        } catch (Exception e) {
            log.error("MessageSendJobTrigger.sendRepaymentRemindMessageForJob异常",e);
        }
    }

    /**
     * 还款逾期定时任务
     */
    @Scheduled(cron = "${message.repayment-overdue}")
    public void sendRepaymentOverdueMessageForJob(){
        try {
            log.info("MessageSendJobTrigger.sendRepaymentOverdueMessageForJob start");
            repaymentDubboService.sendRepaymentOverdueMessageForJob();
            log.info("MessageSendJobTrigger.sendRepaymentOverdueMessageForJob end");
        } catch (Exception e) {
            log.error("MessageSendJobTrigger.sendRepaymentOverdueMessageForJob",e);
        }
    }

}
